<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Partner extends CI_Controller {
	public function index() {
            if($this->session->userdata('isLoggedIn')) {
                
                $this->load->view('crm/portal',$data);                 
            }
            else {
                redirect('login');
            }
           
	}
        
        public function showAddPartnerForm(){
            echo json_encode($data);
        }
        
        public function  hideAddPartnerForm(){
            echo json_encode($data);
        }

        public function addPartner(){
            $partnerName = $this->input->post('partnerName');
            $partnerType = $this->input->post('partnerType');
            $partnerContract = $this->input->post('partnerContract');
            $partnerWebsite = $this->input->post('partnerWebsite');
            $partnerEmail = $this->input->post('partnerEmail');
            $partnerStatus = $this->input->post('partnerStatus');
            $partnerPhone = $this->input->post('partnerPhone');
            $partnerLogo = $this->input->post('partnerLogo');
            $partnerPostAddress = $this->input->post('partnerPostAddress');
            $partnerPostPostalcode = $this->input->post('partnerPostPostalcode');
            $partnerPostPOBox = $this->input->post('partnerPostPOBox');
            $partnerPostCity = $this->input->post('partnerPostCity');
            $partnerVisitorAddress = $this->input->post('partnerVisitorAddress');
            $partnerVisitorPostalcode = $this->input->post('partnerVisitorPostalcode');
            $partnerVisitorCity = $this->input->post('partnerVisitorCity');
            $partnerVisitorExtra = $this->input->post('partnerVisitorExtra');
          
            
            if(!$partnerName || !$partnerType || !$partnerWebsite || !$partnerEmail || !$partnerPhone || !$partnerStatus || !$partnerPostAddress || !$partnerPostCity || !$partnerPostPOBox || !$partnerPostPostalcode || !$partnerVisitorAddress || !$partnerVisitorCity
                    || !$partnerVisitorPostalcode || !$partnerVisitorExtra){
                 $data['error'] = 'Please fill in all required fields.';
                echo json_encode($data);
            }
            else{
                echo json_encode($data);
            }
        }
        
}